<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of add_sponge_nodes</title>
  <meta name="keywords" content="add_sponge_nodes">
  <meta name="description" content="Add a set of sponge nodes comprising a single sponge layer to Mesh structure">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html v1.5 &copy; 2003-2005 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">fvcom_prepro</a> &gt; add_sponge_nodes.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for fvcom_prepro&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>add_sponge_nodes
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Add a set of sponge nodes comprising a single sponge layer to Mesh structure</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [Mobj]  = add_sponge_nodes(Mobj,SpongeName,SpongeRadius,SpongeCoeff) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Add a set of sponge nodes comprising a single sponge layer to Mesh structure  

 [Mobj] = add_sponge_nodes(Mobj)

 DESCRIPTION:
    Select using ginput the set of nodes comprising a sponge layer

 INPUT
    Mobj = Matlab mesh object
    SpongeName = Name of the Sponge Layer
    SpongeRadius = Radius of influence of the Sponge Layer 
    SpongeCoeff  = Sponge damping coefficient

 OUTPUT:
    Mobj = Matlab mesh object with an additional sponge nodelist

 EXAMPLE USAGE
    Mobj = add_sponge_nodes(Mobj,'Sponge1',10000,.0001)

 Author(s):  
    Geoff Cowles (University of Massachusetts Dartmouth)

 Note:
    Uses ginput2 which allows zooming before selecting points and displays
    clicked points realtime

 Revision history
   
==============================================================================</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="find_nearest_pt.html" class="code" title="function [Point,Distance] = find_nearest_pt(xloc,yloc,Mobj)">find_nearest_pt</a>	Find nearest point in Mesh structure to (x,y)</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
<!-- crossreference -->



<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [Mobj]  = add_sponge_nodes(Mobj,SpongeName,SpongeRadius,SpongeCoeff)</a>
0002 
0003 <span class="comment">% Add a set of sponge nodes comprising a single sponge layer to Mesh structure</span>
0004 <span class="comment">%</span>
0005 <span class="comment">% [Mobj] = add_sponge_nodes(Mobj)</span>
0006 <span class="comment">%</span>
0007 <span class="comment">% DESCRIPTION:</span>
0008 <span class="comment">%    Select using ginput the set of nodes comprising a sponge layer</span>
0009 <span class="comment">%</span>
0010 <span class="comment">% INPUT</span>
0011 <span class="comment">%    Mobj = Matlab mesh object</span>
0012 <span class="comment">%    SpongeName = Name of the Sponge Layer</span>
0013 <span class="comment">%    SpongeRadius = Radius of influence of the Sponge Layer</span>
0014 <span class="comment">%    SpongeCoeff  = Sponge damping coefficient</span>
0015 <span class="comment">%</span>
0016 <span class="comment">% OUTPUT:</span>
0017 <span class="comment">%    Mobj = Matlab mesh object with an additional sponge nodelist</span>
0018 <span class="comment">%</span>
0019 <span class="comment">% EXAMPLE USAGE</span>
0020 <span class="comment">%    Mobj = add_sponge_nodes(Mobj,'Sponge1',10000,.0001)</span>
0021 <span class="comment">%</span>
0022 <span class="comment">% Author(s):</span>
0023 <span class="comment">%    Geoff Cowles (University of Massachusetts Dartmouth)</span>
0024 <span class="comment">%</span>
0025 <span class="comment">% Note:</span>
0026 <span class="comment">%    Uses ginput2 which allows zooming before selecting points and displays</span>
0027 <span class="comment">%    clicked points realtime</span>
0028 <span class="comment">%</span>
0029 <span class="comment">% Revision history</span>
0030 <span class="comment">%</span>
0031 <span class="comment">%==============================================================================</span>
0032 subname = <span class="string">'add_sponge_nodes'</span>;
0033 fprintf(<span class="string">'\n'</span>)
0034 fprintf([<span class="string">'begin : '</span> subname <span class="string">'\n'</span>])
0035 
0036 
0037 <span class="comment">%------------------------------------------------------------------------------</span>
0038 <span class="comment">% Plot the mesh</span>
0039 <span class="comment">%------------------------------------------------------------------------------</span>
0040 
0041 <span class="keyword">if</span>(lower(Mobj.nativeCoords(1:3)) == <span class="string">'car'</span>)
0042     x = Mobj.x;
0043     y = Mobj.y;
0044 <span class="keyword">else</span>
0045     x = Mobj.lon;
0046     y = Mobj.lat;
0047 <span class="keyword">end</span>;
0048 
0049 figure
0050 patch(<span class="string">'Vertices'</span>,[x,y],<span class="string">'Faces'</span>,Mobj.tri,<span class="keyword">...</span>
0051         <span class="string">'Cdata'</span>,Mobj.h,<span class="string">'edgecolor'</span>,<span class="string">'k'</span>,<span class="string">'facecolor'</span>,<span class="string">'interp'</span>);
0052 hold on;
0053 
0054 <span class="comment">% use ginput2 (which allows zooming and plots points as they are clicked) to let</span>
0055 <span class="comment">% user select the boundary points</span>
0056 [xselect] = ginput2(true,<span class="string">'k+'</span>)
0057 
0058 
0059 [npts,jnk] = size(xselect);
0060 
0061 <span class="keyword">if</span>(npts == 0)
0062     fprintf(<span class="string">'you didn''t select any points'</span>)
0063     fprintf([<span class="string">'end   : '</span> subname <span class="string">'\n'</span>])
0064     <span class="keyword">return</span>
0065 <span class="keyword">end</span>;
0066 fprintf(<span class="string">'you selected %d points\n'</span>,npts)
0067 
0068 <span class="comment">% snap to the closest vertices</span>
0069 <span class="keyword">for</span> i=1:npts
0070     [ipt(i),dist] = <a href="find_nearest_pt.html" class="code" title="function [Point,Distance] = find_nearest_pt(xloc,yloc,Mobj)">find_nearest_pt</a>(xselect(i,1),xselect(i,2),Mobj);
0071 <span class="keyword">end</span>;
0072 
0073 <span class="comment">% replot domain with snapped vertices</span>
0074 plot(x(ipt),y(ipt),<span class="string">'ro'</span>);
0075 
0076 <span class="comment">% add to mesh object</span>
0077 Mobj.nSponge = Mobj.nSponge + 1;
0078 Mobj.nSpongeNodes(Mobj.nSponge) = npts;
0079 Mobj.sponge_nodes(Mobj.nSponge,1:npts) = ipt;
0080 Mobj.sponge_name{Mobj.nSponge} = SpongeName;
0081 Mobj.sponge_rad(Mobj.nSponge) = SpongeRadius;
0082 Mobj.sponge_fac(Mobj.nSponge) = SpongeCoeff;
0083 
0084 
0085 fprintf([<span class="string">'end   : '</span> subname <span class="string">'\n'</span>])
0086</pre></div>
<hr><address>Generated on Wed 02-Nov-2011 21:58:00 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>